package com.cjc.springcloud.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import com.cjc.springcloud.entity.CommonResult;
import com.cjc.springcloud.entity.Payment;



/**
 * @ClassName Payment
 * @Description: TODO
 * @Author cjc
 * @Date 2020/6/17
 * @Version V1.0
 **/
@RestController
@RequestMapping("order")
public class OrderController {
    private static String url = "http://CLOUD-PROVIDER-PAYMENT";

    @Autowired
    private RestTemplate restTemplate;
    @PostMapping("add")
    public CommonResult add(Payment payment){
      return restTemplate.postForObject(url+"/payment/add",payment,CommonResult.class);
    }
    @GetMapping("getById/{id}")
    public CommonResult<Payment>  getById(@PathVariable("id") Long id){
        return   restTemplate.getForObject(url+"/payment/getById/"+id,CommonResult.class);
    }
}
